use super::hitls_cert_type::HITLS_SignHashAlgo;
use super::hitls_config::{HITLS_DhTmpCb, HITLS_DtlsTimerCb, HITLS_RecordPaddingCb};
use super::hitls_crypt_type::HITLS_CRYPT_Key;
use super::hitls_type::{HITLS_Config, HITLS_Ctx, HITLS_Cipher};
use crate::bsl::bsl_uio::BSL_UIO;

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Create a TLS object and deep copy the HITLS_Config to the HITLS_Ctx.\n\n This is the main TLS structure, which starts to establish a secure link through the client or server\n on the basis that the link has been established at the network layer.\n\n @attention The HITLS_Config can be released after the creation is successful.\n @param   config [IN] Config context\n @retval  HITLS_Ctx pointer. If the operation fails, a null value is returned."]
    pub fn HITLS_New(config: *mut HITLS_Config) -> *mut HITLS_Ctx;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Release the TLS connection.\n\n @param   ctx [IN] TLS connection handle.\n @retval  void"]
    pub fn HITLS_Free(ctx: *mut HITLS_Ctx);
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the UIO object for the HiTLS context.\n\n Bind the HiTLS context to the UIO object, through which the TLS object sends data, reads data,\n and controls the connection status at the network layer.\n After successfully setting, the number of times the UIO object is referenced increases by 1.\n BSL_UIO_Free is called to release the association between the HiTLS and UIO when HITLS_Free is called.\n\n @attention After a HiTLS context is bound to a UIO object, the UIO object cannot be bound to other HiTLS contexts.\n This function must be called before HITLS_Connect and HITLS_Accept.\n @param   ctx [OUT] TLS connection handle.\n @param   uio [IN] UIO object.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_SetUio(ctx: *mut HITLS_Ctx, uio: *mut BSL_UIO) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Read UIO for the HiTLS context.\n\n @attention Must be called before HITLS_Connect and HITLS_Accept and released after HITLS_Free.\n If this function has been called, you must call BSL_UIO_Free to release the UIO.\n @param   ctx [OUT] TLS connection handle.\n @param   uio [IN] UIO object.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_SetReadUio(ctx: *mut HITLS_Ctx, uio: *mut BSL_UIO) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the UIO object from the HiTLS context.\n\n @param   ctx [IN] TLS object.\n @retval  UIO object."]
    pub fn HITLS_GetUio(ctx: *const HITLS_Ctx) -> *mut BSL_UIO;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the UIO object of the read data.\n\n @param   ctx [IN] TLS object\n @retval  UIO object"]
    pub fn HITLS_GetReadUio(ctx: *const HITLS_Ctx) -> *mut BSL_UIO;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   The client starts the handshake with the TLS server.\n\n Starting the handshake with the TLS server using HITLS_Connect.\n The UIO object must be created and bound to the HiTLS context.\n HITLS_Connect is designed as a non-blocking interface. If the handshake cannot be continued,\n the returned value will not be HITLS_SUCCESS.\n If the return value is HITLS_REC_NORMAL_RECV_BUF_EMPTY or HITLS_REC_NORMAL_IO_BUSY,\n no fatal error occurs. Problems such as network congestion or network delay may occur.\n You can continue to call HITLS_Connect. Note that if UIO is blocked, HITLS_Connect will also block,\n but the return value is processed in the same way.\n\n @attention Only clients can call this interface.\n @param   ctx [IN] TLS connection handle.\n @retval  HITLS_SUCCESS\n @retval  HITLS_REC_NORMAL_RECV_BUF_EMPTY, record The receiving buffer is NULL and the handshake can be continued.\n @retval  HITLS_REC_NORMAL_IO_BUSY, the network I/O is busy and needs to wait for the next sending.\n You can continue the handshake.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_Connect(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the initial status of the connection.\n\n @param   ctx [IN] TLS connection handle.\n @param   isClient [IN] Set the current client or server.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_SetEndPoint(ctx: *mut HITLS_Ctx, isClient: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   The server waits for the client to start handshake.\n\n The server waits for the client to initiate the handshake.\n The UIO object must be created and bound to the HiTLS context.\\n\n HITLS_Accept is designed for non-blocking interfaces.\n If the handshake cannot be continued, the system returns. The return value is not success.\n If the return value is HITLS_REC_NORMAL_RECV_BUF_EMPTY or HITLS_REC_NORMAL_IO_BUSY, no fatal error occurs.\n Problems such as network congestion or network delay may occur. You can continue to call HITLS_Accept.\n Note that if the UIO is blocked, the HITLS_Accept will also be blocked, but the processing\n of the returned value is the same.\n\n @attention Only the server calls this API.\n @param   ctx [IN] TLS connection handle.\n @retval  HITLS_SUCCESS, the handshake is successful.\n @retval  HITLS_REC_NORMAL_RECV_BUF_EMPTY, record The receiving buffer is NULL and the handshake can continue.\n @retval  HITLS_REC_NORMAL_IO_BUSY, the network I/O is busy and needs to wait for the next sending.\n You can continue the handshake.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_Accept(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Read application data\n\n @attention Only the application data decrypted by one record can be read by HiTLS at a time\n HiTLS copies the application data to the input cache.\n If the cache size is less than 16 KB, the maximum size of the application message decrypted\n by a single record is 16 KB. This will result in a partial copy of the application data\n You can call HITLS_GetReadPendingBytes to obtain the size of the remaining readable application data\n in the current record. This is useful in DTLS scenarios.\n @param   ctx [IN] TLS context\n @param   data [OUT] Read data\n @param   bufSize [IN] Size of the buffer\n @param   readLen [OUT] Read length\n @retval  HITLS_SUCCESS, if successful\n @retval  HITLS_REC_NORMAL_RECV_BUF_EMPTY, record The receiving buffer is NULL and can be read again.\n @retval  HITLS_REC_NORMAL_IO_BUSY, the network I/O is busy and needs to wait for the next sending\n You can continue to read the I/O.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_Read(ctx: *mut HITLS_Ctx, data: *mut u8, bufSize: u32, readLen: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   read application data from a TLS/SSL connection\n @attention HITLS_Peek() is identical to HITLS_Read() except no bytes are actually\nremoved from the underlying BIO during the read\n @param   ctx [IN] TLS context\n @param   data [OUT] data buffer\n @param   bufSize [IN] data buffer size\n @param   readLen [OUT] store the number of bytes actually read in *readLen\n @retval  HITLS_SUCCESS\n @retval  HITLS_REC_NORMAL_RECV_BUF_EMPTY, read buffer is empty, more bytes can be read.\n @retval  HITLS_REC_NORMAL_IO_BUSY, IO budy, waiting for next calling to read more.\n @retval  Refer to hitls_error.h for more"]
    pub fn HITLS_Peek(ctx: *mut HITLS_Ctx, data: *mut u8, bufSize: u32, readLen: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Write data.\n\n Encrypts and packs data with the specified length dataLen into a single record and sends the record.\n\n @attention The length of the data to be sent cannot exceed the maximum writable length,\n            which can be obtained by calling HITLS_GetMaxWriteSize.\n @param   ctx [IN] TLS context\n @param   data [IN] Data to be written\n @param   dataLen [IN] Length to be written\n @param   writeLen [OUT] Length of Successful Writes\n @retval  HITLS_SUCCESS is sent successfully.\n @retval  HITLS_REC_NORMAL_RECV_BUF_EMPTY, record If the receiving buffer is NULL, the message can be sent again.\n @retval  HITLS_REC_NORMAL_IO_BUSY, The network I/O is busy and needs to wait for the next sending.\n                                   You can continue sending the I/O.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_Write(
        ctx: *mut HITLS_Ctx,
        data: *const u8,
        dataLen: u32,
        writeLen: *mut u32,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the maximum writable (plaintext) length.\n\n @param   ctx [OUT] TLS connection handle.\n @param   len [OUT] Maximum writable plaintext length (within 16 KB)\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_GetMaxWriteSize(ctx: *const HITLS_Ctx, len: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain user data from the HiTLS context. This interface is called in the callback registered with the HiTLS.\n\n @attention must be called before HITLS_Connect and HITLS_Accept.\n            The life cycle of the user data pointer must be longer than the life cycle of the TLS object.\n @param   ctx [OUT] TLS connection handle.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, the TLS object pointer of the input parameter is null."]
    pub fn HITLS_GetUserData(ctx: *const HITLS_Ctx) -> *mut ::std::os::raw::c_void;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Save the user data in the HiTLS context, which can be obtained from the callback registered with the HiTLS.\n\n @attention must be called before HITLS_Connect and HITLS_Accept.\n The life cycle of the user data pointer must be greater than the life cycle of the TLS object.\\n\n If the user data needs to be cleared, the HITLS_SetUserData(ctx, NULL) interface can be called directly.\n The Clean interface is not provided separately.\n @param   ctx [OUT] TLS connection handle.\n @param   userData [IN] Pointer to the user data.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, the TLS object pointer of the input parameter is null."]
    pub fn HITLS_SetUserData(ctx: *mut HITLS_Ctx, userData: *mut ::std::os::raw::c_void) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Close the TLS connection.\n\n If the peer end is not closed, the system sends a closed notify message to the peer end.\n HITLS_Close must not be called if a fatal error has occurred on the link.\n\n @param   ctx [IN] TLS connection handle.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_Close(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the shutdown status of the TLS link.\n\n In HITLS_Close, if the peer end is not closed, a closed notification message is sent to the peer end.\n When the local end sends a closed notify message, the HiTLS sets the HITLS_SENT_SHUTDOWN flag bit.\n When the local end receives the closed notify message, the HiTLS sets the HITLS_RECEIVED_SHUTDOWN flag bit.\n By default, the HiTLS needs to send and receive closed notifications.\n The actual condition for properly closing a session is HITLS_SENT_SHUTDOWN. (According to the TLS RFC,\n it is acceptable to send only close_notify alerts without waiting for a reply from the peer.)\n If HITLS_RECEIVED_SHUTDOWN is set, it indicates that the peer end does not need to wait for the closed notification.\n\n @param   ctx [IN] TLS connection handle.\n @param   mode [IN] TLS shutdown status: HITLS_SENT_SHUTDOWN / HITLS_RECEIVED_SHUTDOWN.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_SetShutdownState(ctx: *mut HITLS_Ctx, mode: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the shutdown status of the TLS link.\n\n @param   ctx [IN] TLS connection handle.\n @param   mode [OUT] TLS shutdown status: HITLS_SENT_SHUTDOWN / HITLS_RECEIVED_SHUTDOWN.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_GetShutdownState(ctx: *const HITLS_Ctx, mode: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the HiTLS negotiation version.\n\n @param   ctx [IN] TLS object\n @param   version [OUT] Negotiated version\n @retval  HITLS_SUCCESS, obtained successfully.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetNegotiatedVersion(ctx: *const HITLS_Ctx, version: *mut u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the latest protocol version.\n\n @param   ctx [IN] TLS object\n @param   maxVersion [OUT] Latest protocol version supported\n @retval  HITLS_SUCCESS, obtained successfully.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetMaxProtoVersion(ctx: *const HITLS_Ctx, maxVersion: *mut u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the latest protocol version.\n\n @param   ctx [IN] TLS object\n @param   maxVersion [OUT] Latest protocol version supported\n @retval  HITLS_SUCCESS, obtained successfully.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetMinProtoVersion(ctx: *const HITLS_Ctx, minVersion: *mut u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the minimum protocol version based on the specified version.\n\n @param   ctx [OUT] TLS object\n @param   versiion [IN] The given version\n @attention   The maximum version number and minimum version number must be both TLS and DTLS. Currently,\n only DTLS 1.2 is supported. This interface is used together with the full configuration interfaces,\n such as HITLS_CFG_NewDTLSConfig and HITLS_CFG_NewTLSConfig.\n If the TLS full configuration is configured, only the TLS version can be set.\n If full DTLS configuration is configured, only the DTLS version can be set.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_SetMinProtoVersion(ctx: *mut HITLS_Ctx, version: u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the maximum protocol version that is supported based on the specified version.\n\n @param   ctx [OUT] TLS object\n @param   versiion [IN] The given version\n @attention   The maximum version number and minimum version number must be both TLS and DTLS. Currently,\n only DTLS 1.2 is supported. This function is used together with the full configuration interfaces,\n such as HITLS_CFG_NewDTLSConfig and HITLS_CFG_NewTLSConfig.\n If the TLS full configuration is configured, only the TLS version can be set.\n If full DTLS configuration is configured, only the DTLS version can be set.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_SetMaxProtoVersion(ctx: *mut HITLS_Ctx, version: u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain whether to use the AEAD algorithm.\n\n @param   ctx [IN] TLS object\n @param   isAead [OUT] Indicates whether to use the AEAD algorithm.\n @retval  HITLS_SUCCESS, obtained successfully.\n          HITLS_NULL_INPUT, The input parameter pointer is null."]
    pub fn HITLS_IsAead(ctx: *const HITLS_Ctx, isAead: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Check whether DTLS is used.\n\n @param   ctx [IN] TLS object\n @param   isDtls [OUT] Indicates whether to use DTLS.\n @retval  HITLS_SUCCESS, is obtained successfully.\n          HITLS_NULL_INPUT, The input parameter pointer is null."]
    pub fn HITLS_IsDtls(ctx: *const HITLS_Ctx, isDtls: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Record the error value of the HiTLS link.\n\n @param   ctx [OUT] TLS connection handle\n @param   errorCode [IN] Error value\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_SetErrorCode(ctx: *mut HITLS_Ctx, errorCode: i32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the error value of the HiTLS link.\n\n @param   ctx [OUT] TLS connection handle\n @retval  Link error value"]
    pub fn HITLS_GetErrorCode(ctx: *const HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the information about whether the handshake is complete.\n\n @param   ctx [OUT] TLS connection handle\n @param   isDone [IN] Indicates whether the handshake is complete.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_IsHandShakeDone(ctx: *const HITLS_Ctx, isDone: *mut u8) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Indicates whether the HiTLS object functions as the server.\n\n @param   ctx [OUT] TLS connection handle\n @param   isServer [IN] Indicates whether to function as the server.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_IsServer(ctx: *const HITLS_Ctx, isServer: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Check the HiTLS object in the read cache.\n\n (including processed and unprocessed data, excluding the network layer) Whether there is data\n\n @param   ctx [IN] TLS connection handle\n @param   isPending [OUT] Whether there is data. The options are as follows: 1: yes; 0: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_ReadHasPending(ctx: *const HITLS_Ctx, isPending: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the number of bytes of application data to be read from the current record from the HiTLS object.\n\n @attention When the HiTLS works in data packet transmission (DTLS), the HITLS_Read may\n copy part of the application packet because the input buffer is not large enough.\n This function is used to obtain the remaining size of the application packet.\n This is useful for transport over DTLS.\n @param   ctx [IN] TLS connection handle\n @retval  Number of bytes of application data that can be read."]
    pub fn HITLS_GetReadPendingBytes(ctx: *const HITLS_Ctx) -> u32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the signature hash algorithm used by the peer end.\n\n @param   ctx [IN] TLS connection handle\n @param   peerSignScheme [OUT] Peer signature hash algorithm\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_GetPeerSignScheme(
        ctx: *const HITLS_Ctx,
        peerSignScheme: *mut HITLS_SignHashAlgo,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the signature hash algorithm used by the local end.\n\n @param   ctx [IN] TLS connection handle\n @param   localSignScheme [OUT] Local signature hash algorithm\n @retval  HITLS_SUCCESS, if successful.\n @retval  For other error codes, see hitls_error.h."]
    pub fn HITLS_GetLocalSignScheme(
        ctx: *const HITLS_Ctx,
        localSignScheme: *mut HITLS_SignHashAlgo,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief Set the group supported by the hitls object.\n\n @param ctx [OUT] hitls context\n @param lst [IN] group list\n @param groupSize [IN] List length\n @retval HITLS_SUCCESS is set successfully.\n For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetEcGroups(ctx: *mut HITLS_Ctx, lst: *mut u16, groupSize: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the signature algorithm supported by the hitls object.\n\n @param   ctx [OUT] hitls context.\n @param   signAlgs [IN] List of supported signature algorithms.\n @param   signAlgsSize [IN] Length of the signature algorithm list.\n @retval  HITLS_SUCCESS, set successfully.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetSigalgsList(
        ctx: *mut HITLS_Ctx,
        signAlgs: *const u16,
        signAlgsSize: u16,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the EC point format of the hitls.\n\n @attention Currently, the value can only be HITLS_ECPOINTFORMAT_UNCOMPRESSED.\n @param   ctx [OUT] hitls context.\n @param   pointFormats [IN] ec point format, corresponding to the HITLS_ECPointFormat enumerated value.\n @param   pointFormatsSize [IN] Length of the ec point format\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetEcPointFormats(
        ctx: *mut HITLS_Ctx,
        pointFormats: *const u8,
        pointFormatsSize: u32,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set whether to verify the client certificate.\n\n @param   ctx [OUT] TLS connection handle\n @param   support [IN] Indicates whether to verify the client certificate, the options are\n as follows: true: yes; false: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_SetClientVerifySupport(ctx: *mut HITLS_Ctx, support: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set whether to support the function without the client certificate, Takes effect only when the client\n certificate is verified.\n\n Client: This setting has no impact.\n Server: When an NULL certificate is received from the client, indicates whether the certificate passes\n         the verification, the verification fails by default.\n\n @param   ctx [OUT] TLS connection handle\n @param   support [IN] Indicates whether the authentication is successful when there is no client certificate.\ntrue: If the certificate sent by the client is NULL, the server still passes the verification.\nfalse: If the certificate sent by the client is NULL, the server fails the verification.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_SetNoClientCertSupport(ctx: *mut HITLS_Ctx, support: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set whether to support post-handshake AUTH.\n\n @param   ctx [OUT] TLS connection handle\n @param   support [IN] true: yes; false: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_SetPostHandshakeAuthSupport(ctx: *mut HITLS_Ctx, support: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set whether to support do not proceed dual-ended verification.\n\n @param   ctx [OUT] TLS connection handle\n @param   support [IN] true: yes; false: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_SetVerifyNoneSupport(ctx: *mut HITLS_Ctx, support: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set whether the client certificate can be requested only once.\n\n @param   ctx [OUT] TLS connection handle\n @param   support [IN] true: yes; false: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_SetClientOnceVerifySupport(ctx: *mut HITLS_Ctx, support: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the value of hitlsConfig.\n\n @param   ctx [IN] TLS connection handle\n @retval  NULL, The input parameter pointer is null.\n @retval  hitlsConfig in ctx."]
    pub fn HITLS_GetConfig(ctx: *const HITLS_Ctx) -> *const HITLS_Config;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the point of GlobalConfig\n @param   ctx [IN] TLS connection handle\n @retval  NULL The input parameter pointer is null\n @retval  GlobalConfig in ctx"]
    pub fn HITLS_GetGlobalConfig(ctx: *const HITLS_Ctx) -> *mut HITLS_Config;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Clears the configured TLS1.3 cipher suite.\n\n @param   ctx [IN] TLS connection handle.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_ClearTLS13CipherSuites(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief    Set the supported cipher suites.\n\n The sequence of the cipher suites affects the priority of the selected cipher suites.\n The cipher suites with the highest priority are selected first.\n\n @attention Do not check the cipher suite to meet the changes in the supported version.\n @param   ctx [OUT] TLS connection handle.\n @param   cipherSuites [IN] Key suite array, corresponding to the HITLS_CipherSuite enumerated value.\n @param   cipherSuitesSize [IN] Key suite array length.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetCipherSuites(
        ctx: *mut HITLS_Ctx,
        cipherSuites: *const u16,
        cipherSuitesSize: u32,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the negotiated cipher suite pointer.\n\n @param   ctx  [IN] TLS connection handle\n @retval  Pointer to the negotiated cipher suite.\n          NULL, the input parameter pointer is null."]
    pub fn HITLS_GetCurrentCipher(ctx: *const HITLS_Ctx) -> *const HITLS_Cipher;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the random number of the client and server during the handshake.\n\n @param   ctx  [IN] TLS connection handle\n @param   out  [OUT] Random number obtained\n @param   outlen  [OUT] Length of the input parameter out.\n                        If the length is greater than the maximum random number length, the value will be changed.\n @param   isClient  [IN] True, obtain the random number of the client.\n                         False, obtain the random number of the server.\n @retval  HITLS_SUCCESS, obtaining the status succeeded.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetHsRandom(
        ctx: *const HITLS_Ctx,
        out: *mut u8,
        outlen: *mut u32,
        isClient: bool,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the current handshake status.\n\n @param   ctx  [IN] TLS connection handle\n @param   state  [OUT] Current handshake status\n @retval  HITLS_SUCCESS, Obtaining the status succeeded.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetHandShakeState(ctx: *const HITLS_Ctx, state: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @brief   Obtain the handshake status character string.\n\n @param   state [IN] Handshake status\n @retval  Character string corresponding to the handshake status"]
    pub fn HITLS_GetStateString(state: u32) -> *const ::std::os::raw::c_char;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Check whether a handshake is being performed.\n\n @param   ctx  [IN] TLS connection handle\n @param   isHandShaking  [OUT] Indicates whether the handshake is in progress.\n @retval  HITLS_SUCCESS, Obtaining the status succeeded.\n          For other error codes, see hitls_error.h."]
    pub fn HITLS_IsHandShaking(ctx: *const HITLS_Ctx, isHandShaking: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain whether renegotiation is supported.\n\n @param   ctx [IN] hitls Context\n @param   isSupportRenegotiation [OUT] Whether to support renegotiation\n @retval  HITLS_SUCCESS, obtain successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetRenegotiationSupport(
        ctx: *const HITLS_Ctx,
        isSupportRenegotiation: *mut bool,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Check whether the handshake has not been performed.\n\n @param   ctx [IN] TLS connection handle\n @param   isBefore [OUT] Indicates whether the handshake has not been performed.\n @retval  HITLS_SUCCESS, obtaining the status succeeded.\n          For other error codes, see hitls_error.h."]
    pub fn HITLS_IsBeforeHandShake(ctx: *const HITLS_Ctx, isBefore: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the MTU of Data Link layer.\n\n @param   ctx  [IN] TLS connection handle\n @param   linkMtu  [IN] MTU of Data Link layer.\n @retval  HITLS_SUCCESS, set the mtu succeeded.\n @retval  HITLS_CONFIG_INVALID_LENGTH, the mtu is invalid\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetLinkMtu(ctx: *mut HITLS_Ctx, linkMtu: u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the MTU of a path.\n\n @param   ctx  [IN] TLS connection handle\n @param   mtu  [IN] Set the MTU.\n @retval  HITLS_SUCCESS, set the mtu succeeded.\n @retval  HITLS_CONFIG_INVALID_LENGTH, the mtu is invalid\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetMtu(ctx: *mut HITLS_Ctx, mtu: u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the option that don't query mtu from the bio.\n\n @param   ctx  [IN] TLS connection handle\n @param   noQueryMtu  [IN] whether not to query the mtu from the bio.\n @retval  HITLS_SUCCESS, set the option succeeded.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetNoQueryMtu(ctx: *mut HITLS_Ctx, noQueryMtu: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Querying whether the EMSGSIZE error occur and mtu need be modified\n\n @param   ctx [IN] TLS connection handle.\n @param   needQueryMtu [IN] Indicates whether the EMSGSIZE error occur and mtu need be modified\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetNeedQueryMtu(ctx: *mut HITLS_Ctx, needQueryMtu: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the version number set by the client in ClientHello.\n\n @param   ctx  [IN] TLS connection handle\n @param   clientVersion [OUT] Obtained version number\n @retval  HITLS_SUCCESS, obtaining the status succeeded.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetClientVersion(ctx: *const HITLS_Ctx, clientVersion: *mut u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   The client/server starts handshake.\n\n @attention In the IDLE state, the HITLS_SetEndPoint must be called first.\n @param   ctx  [IN] TLS connection handle\n @retval  HITLS_SUCCESS, obtaining the status succeeded.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_DoHandShake(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Check whether the current end is client.\n\n @param   ctx  [IN] TLS connection handle\n @param   isClient  [OUT] Client or not.\n @retval  HITLS_SUCCESS, obtaining the status succeeded.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_IsClient(ctx: *const HITLS_Ctx, isClient: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the keyupdate type of the current context and send the keyupdate message.\n\n @param   ctx  [IN] TLS connection handle\n @param   updateType [IN] keyupdate type\n @retval  HITLS_SUCCESS, if successful.\n          For other error codes, see hitls_error.h."]
    pub fn HITLS_KeyUpdate(ctx: *mut HITLS_Ctx, updateType: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Return the keyupdate type of the current context.\n\n @param   ctx  [IN] TLS connection handle\n @retval  KeyUpdateType in ctx\n @retval  NULL, the input parameter pointer is null."]
    pub fn HITLS_GetKeyUpdateType(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the supported peer group or the number of supported peer groups of the nth match.\n\n nmatch Value range: - 1 or a positive integer\n This function can be called only after negotiation and can be called only by the server.\n If nmatch is a positive integer, check the intersection of groups on the client and server,\n and return the nmatch group in the intersection by groupId.\n If the value of nmatch is - 1, the number of intersection groups on the client and server is\n returned based on groupId.\n\n @param   ctx  [IN] TLS connection handle.\n @param   nmatch  [IN] Sequence number of the group to be obtained, -1 Return the number of supported peer groups.\n @param   groupId  [OUT] Returned result.\n @retval  HITLS_SUCCESS, Obtaining the status succeeded.\n          For details about other error codes, see hitls_error.h.\n"]
    pub fn HITLS_GetSharedGroup(ctx: *const HITLS_Ctx, nmatch: i32, groupId: *mut u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the DTLS timeout interval callback.\n @param   ctx [IN] TLS connection handle.\n @param   cb [IN] DTLS obtaining timeout interval callback.\n @return  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetDtlsTimerCb(ctx: *mut HITLS_Ctx, cb: HITLS_DtlsTimerCb) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the supported version number.\n\n @param   ctx [IN] TLS connection handle.\n @param   version [OUT] Supported version number.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_GetVersionSupport(ctx: *const HITLS_Ctx, version: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the supported version number.\n\n @param   ctx  [OUT] TLS connection handle\n @param   version [IN] Supported version number.\n @attention   The maximum version number and minimum version number must be both TLS and DTLS. Currently,\n only DTLS 1.2 is supported. This function is used together with the full configuration interfaces,\n such as HITLS_CFG_NewDTLSConfig and HITLS_CFG_NewTLSConfig.\n     If the TLS full configuration is configured, only the TLS version can be set. If full DTLS configuration\n is configured, only the DTLS version can be set.\n     The versions must be consecutive. By default, the minimum and maximum versions are supported.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_SetVersionSupport(ctx: *mut HITLS_Ctx, version: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the supported version number range.\n\n @param   ctx  [OUT] TLS connection handle\n @param   minVersion [IN] Minimum version number supported.\n @param   maxVersion [IN] Maximum version number supported.\n @attention   The maximum version number and minimum version number must be both TLS and DTLS.\n     Currently, only DTLS 1.2 is supported. This function is used together with the full configuration interfaces,\n such as HITLS_CFG_NewDTLSConfig and HITLS_CFG_NewTLSConfig.\n     If the TLS full configuration is configured, only the TLS version can be set. If full DTLS configuration is\n configured, only the DTLS version can be set.\n @retval HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_SetVersion(ctx: *mut HITLS_Ctx, minVersion: u32, maxVersion: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the version number to be disabled.\n\n @param   ctx  [OUT] TLS connection handle\n @param   noVersion [IN] Disabled version number.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_SetVersionForbid(ctx: *mut HITLS_Ctx, noVersion: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets whether to verify the version in the premaster secret.\n\n @param   ctx  [OUT] TLS Connection Handle.\n @param   needCheck [IN] Indicates whether to perform check.\n @attention   This parameter is valid for versions earlier than TLS1.1.\n     true indicates that verification is supported, and false indicates that verification is not supported. In\n this case, rollback attacks may occur. For versions later than TLS1.1, forcible verification is supported.\n This interface takes effect on the server.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, config is null."]
    pub fn HITLS_SetNeedCheckPmsVersion(ctx: *mut HITLS_Ctx, needCheck: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the silent disconnection mode.\n\n @param   ctx [IN] TLS connection handle.\n @param   mode [IN] Mode type. The value 0 indicates that the quiet disconnection mode is disabled, and the value 1\n indicates that the quiet disconnection mode is enabled.\n @retval  HITLS_SUCCESS, if successful.\n For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetQuietShutdown(ctx: *mut HITLS_Ctx, mode: i32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the current silent disconnection mode.\n\n @param   ctx [IN] TLS connection handle\n @param   mode [OUT] Mode type.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetQuietShutdown(ctx: *const HITLS_Ctx, mode: *mut i32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets whether to support the function of automatically selecting DH parameters.\n\n If the value is true, the DH parameter is automatically selected based on the length of the certificate private key.\n If the value is false, the DH parameter needs to be set.\n\n @param   ctx  [IN/OUT] hitls context.\n @param   support [IN] Whether to support. The options are as follows: true: yes; false: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is null."]
    pub fn HITLS_SetDhAutoSupport(ctx: *mut HITLS_Ctx, support: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the DH parameter specified by the user.\n\n @param   ctx [IN/OUT] hitls context.\n @param   dhPkey [IN] User-specified DH key.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT ctx or dhPkey field is NULL"]
    pub fn HITLS_SetTmpDh(ctx: *mut HITLS_Ctx, dhPkey: *mut HITLS_CRYPT_Key) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the TmpDh callback function.\n @param   ctx [IN/OUT] TLS connection handle.\n @param   callback [IN] Set the TmpDh callback.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetTmpDhCb(ctx: *mut HITLS_Ctx, callback: HITLS_DhTmpCb) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets the RecordPadding callback.\n\n @param   ctx [IN/OUT] TLS Connection Handle\n @param   callback [IN] Sets the RecordPadding callback.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetRecordPaddingCb(ctx: *mut HITLS_Ctx, callback: HITLS_RecordPaddingCb) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtains the RecordPadding callback function.\n\n @param   ctx [IN/OUT] TLS Connection Handle\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetRecordPaddingCb(ctx: *mut HITLS_Ctx) -> HITLS_RecordPaddingCb;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets the parameters arg required by the RecordPadding callback function.\n\n @param   ctx [IN/OUT] TLS Connection Handle\n @param   arg [IN] Related Parameter arg\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetRecordPaddingCbArg(
        ctx: *mut HITLS_Ctx,
        arg: *mut ::std::os::raw::c_void,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtains the parameter arg required by the RecordPadding callback function.\n\n @param   ctx [IN/OUT] TLS Connection Handle\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetRecordPaddingCbArg(ctx: *mut HITLS_Ctx) -> *mut ::std::os::raw::c_void;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the verification data and length of the peer end based on the received finished message.\n\n @param   ctx [IN] TLS context\n @param   buf [OUT] verify data\n @param   bufLen [IN] Length of the buffer to be obtained\n @param   dataLen [OUT] Actual length of the buf\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetPeerFinishVerifyData(
        ctx: *const HITLS_Ctx,
        buf: *mut ::std::os::raw::c_void,
        bufLen: u32,
        dataLen: *mut u32,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Disables the verification of keyusage in the certificate. This function is enabled by default.\n\n @param   ctx [OUT] config context\n @param   isCheck [IN] Sets whether to check key usage.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetCheckKeyUsage(ctx: *mut HITLS_Ctx, isCheck: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the verification data and length of the local end based on the sent finished message.\n\n @param   ctx [IN] TLS context\n @param   buf [OUT] verify data\n @param   bufLen [IN] Length of the buffer to be obtained\n @param   dataLen [OUT] Indicates the actual length of the buffer\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetFinishVerifyData(
        ctx: *const HITLS_Ctx,
        buf: *mut ::std::os::raw::c_void,
        bufLen: u32,
        dataLen: *mut u32,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtains whether security renegotiation is supported.\n\n @param   ctx [IN] hitls context.\n @param   isSecureRenegotiation [OUT] Whether to support security renegotiation\n @retval  HITLS_SUCCESS, obtained successfully.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetSecureRenegotiationSupport(
        ctx: *const HITLS_Ctx,
        isSecureRenegotiation: *mut bool,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief Perform renegotiation.\n\n @attention 1. After this interface is called, the user needs to call one of the\n               HITLS_Connect / HITLS_Accept / HITLS_Read / HITLS_Write interfaces again,\n               The HITLS_Renegotiate interface is used only for setting and initialization of renegotiation,\n               The renegotiation process is performed when the user calls the\n               HITLS_Connect / HITLS_Accept / HITLS_Read / HITLS_Write.\n            2. You are advised to use the HITLS_Connect / HITLS_Accept interface for renegotiation.\n               After the negotiation is complete, call the HITLS_Read / HITLS_Write interface.\n            3. If the user uses HITLS_Read to perform renegotiation,\n               the user may receive the app message from the peer end during the renegotiation.\n               (1) If the renegotiation has not started, the HiTLS will return the message to the user.\n               (2) If the renegotiation is in progress, no app message is received in this scenario,\n                   and the HiTLS sends an alert message to disconnect the link.\n            4. If the user uses the HITLS_Connect / HITLS_Accept / HITLS_Write for renegotiation,\n               the user may receive the app message from the peer end during the renegotiation,\n               HiTLS caches the message, the message is returned when a user calls HITLS_Read.\n               Maximum of 50 app messages can be cached, if the cache is full, subsequent app messages will be\n               ignored.\n            5. In the DTLS over UDP scenario, if the user functions as the server,\n               packet loss occurs in the renegotiation request(hello request).\n               (1) If the user calls the HITLS_Write for renegotiation, the app message to be sent is\n                   sent to the peer end after packet loss occurs in the renegotiation request.\n               (2) The HiTLS does not retransmit the renegotiation request. The user needs to call the\n                   HITLS_Renegotiate and HITLS_Accept interfaces again to continue the renegotiation.\n                   You can call the HITLS_GetRenegotiationState interface to determine\n                   whether the current renegotiation is in the renegotiation state,\n                   If the renegotiation is not in the renegotiation state,\n                   call the HITLS_Renegotiate and HITLS_Accept interfaces again to continue the renegotiation.\n            6. In the DTLS over UDP scenario, if the user as the client,\n               packet loss occurs in the renegotiation request (client hello).\n               (1) If the user calls the HITLS_Write to perform renegotiation, the app message is not\n                   sent to the peer end after packet loss occurs in the renegotiation request.\n                   Instead, the user waits for the response from the peer end.\n               (2) The client hello message is retransmitted inside the HiTLS,\n                   and the user does not need to initiate renegotiation again.\n @param   ctx  [IN] TLS Connection Handle\n\n @retval  HITLS_SUCCESS, if successful.\n @retval  For details about other error codes, see hitls_error.h."]
    pub fn HITLS_Renegotiate(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the current is whether in the renegotiation state.\n\n @attention For the server, the server does not enter the renegotiation state by sending only the hello request\n message, The server enters the renegotiation state only after receiving the client hello message.\n\n @param   ctx  [IN] TLS Connection Handle.\n @param   isRenegotiationState  [OUT] Indicates whether the renegotiation is in the renegotiation state.\n true: in the renegotiation state; false: not in the renegotiation state.\n\n @retval  HITLS_SUCCESS, if successful.\n @retval  For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetRenegotiationState(
        ctx: *const HITLS_Ctx,
        isRenegotiationState: *mut bool,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the current internal status.\n\n @param   ctx  [IN] TLS connection Handle.\n @param   rwState  [OUT] Current internal status information.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For details about other error codes, see hitls_error.h."]
    pub fn HITLS_GetRwstate(ctx: *const HITLS_Ctx, rwstate: *mut u8) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Check whether the client certificate can be verified.\n\n @param   ctx  [IN] TLS connection Handle.\n @param   isSupport   [OUT] Indicates whether to verify the client certificate.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is null."]
    pub fn HITLS_GetClientVerifySupport(ctx: *mut HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Check whether no client certificate is supported, This command is valid only when client certificate\n verification is enabled.\n\n @param   ctx  [IN] TLS Connection Handle.\n @param   isSupport   [OUT] Whether no client certificate is supported.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is null."]
    pub fn HITLS_GetNoClientCertSupport(ctx: *mut HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Query whether post-handshake AUTH is supported\n\n @param   ctx  [IN] TLS connection Handle.\n @param   isSupport   [OUT] indicates whether to support post-handshake AUTH.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is null."]
    pub fn HITLS_GetPostHandshakeAuthSupport(ctx: *mut HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Query if support is available for not performing dual-end verification.\n\n @param   ctx  [IN] TLS Connection Handle.\n @param   isSupport   [OUT] if support is available for not performing dual-end verification.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is null."]
    pub fn HITLS_GetVerifyNoneSupport(ctx: *mut HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Query whether the client certificate can be requested only once.\n\n @param   ctx  [IN] TLS Connection Handle.\n @param   isSupport   [OUT] Indicates whether the client certificate can be requested only once.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is null."]
    pub fn HITLS_GetClientOnceVerifySupport(ctx: *mut HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Clears the renegotiation count.\n\n @param   ctx [IN] hitls context.\n @param   renegotiationNum [OUT] Number of incoming renegotiations.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_ClearRenegotiationNum(ctx: *mut HITLS_Ctx, renegotiationNum: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the negotiated group information.\n\n @param   ctx  [IN] TLS Connection Handle.\n @param   group   [OUT] Negotiated group information.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is null."]
    pub fn HITLS_GetNegotiateGroup(ctx: *const HITLS_Ctx, group: *mut u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the function to support the specified feature.\n\n @param   ctx [OUT] TLS Connection Handle\n @param   mode [IN] Mode features to enabled.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is null.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetModeSupport(ctx: *mut HITLS_Ctx, mode: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Function to clear the specified feature.\n\n @param   ctx [OUT] TLS Connection Handle\n @param   mode [IN] Mode features to clear.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is null.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_ClearModeSupport(ctx: *mut HITLS_Ctx, mode: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the mode of the function feature in the config file.\n\n @param   ctx [OUT] TLS Connection Handle\n @param   mode [OUT] Mode obtain the output parameters of the mode.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is null.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetModeSupport(ctx: *const HITLS_Ctx, mode: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Setting the Encrypt-Then-Mac mode.\n\n @param   ctx [IN] TLS connection handle.\n @param   encryptThenMacType [IN] Current Encrypt-Then-Mac mode.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetEncryptThenMac(ctx: *mut HITLS_Ctx, encryptThenMacType: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtains the Encrypt-Then-Mac type\n\n @param   ctx [IN] TLS connection Handle.\n @param   encryptThenMacType [OUT] Current Encrypt-Then-Mac mode.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetEncryptThenMac(ctx: *const HITLS_Ctx, encryptThenMacType: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Setting the value of server_name.\n\n @param   ctx [IN] TLS connection handle.\n @param   serverName  [IN] serverName.\n @param   serverNameStrlen [IN] serverName length.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_SetServerName(
        ctx: *mut HITLS_Ctx,
        serverName: *mut u8,
        serverNameStrlen: u32,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   The algorithm suite can be preferentially selected from the algorithm list supported by the server.\n\n @param   ctx [IN] TLS Connection Handle.\n @param   isSupport [IN] Support or Not.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetCipherServerPreference(ctx: *mut HITLS_Ctx, isSupport: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtains whether the current cipher suite supports preferential selection\n from the list of algorithms supported by the server.\n\n @param   ctx [IN] TLS connection handle.\n @param   isSupport [OUT] Support or Not.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetCipherServerPreference(ctx: *const HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets whether to support renegotiation.\n\n @param   ctx   [IN/OUT] TLS connection handle.\n @param   isSupport  [IN] Support or Not, true: yes; false: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL."]
    pub fn HITLS_SetRenegotiationSupport(ctx: *mut HITLS_Ctx, isSupport: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set whether to allow a renegotiate request from the client\n @param   ctx   [IN/OUT] TLS connection handle.\n @param   isSupport  [IN] Support or Not, true: yes; false: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL."]
    pub fn HITLS_SetClientRenegotiateSupport(ctx: *mut HITLS_Ctx, isSupport: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set whether to abort handshake when server doesn't support SecRenegotiation\n @param   ctx   [IN/OUT] TLS connection handle.\n @param   isSupport  [IN] Support or Not, true: yes; false: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL."]
    pub fn HITLS_SetLegacyRenegotiateSupport(ctx: *mut HITLS_Ctx, isSupport: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets whether to support session tickets.\n\n @param   ctx  [IN/OUT] TLS connection handle.\n @param   isSupport [IN] whether to support session tickets, true: yes; false: no\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL."]
    pub fn HITLS_SetSessionTicketSupport(ctx: *mut HITLS_Ctx, isSupport: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Check whether the session ticket is supported.\n\n @param   ctx  [IN] TLS connection handle.\n @param   isSupport [OUT] whether to support session tickets, true: yes; false: no\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL."]
    pub fn HITLS_GetSessionTicketSupport(ctx: *const HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets whether to perform cookie exchange in the dtls.\n\n @param   ctx [IN] TLS connection handle.\n @param   isSupport [IN] Indicates whether to perform cookie exchange\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetDtlsCookieExangeSupport(ctx: *mut HITLS_Ctx, isSupport: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Querying whether the DTLS performs cookie exchange.\n\n @param   ctx [IN] TLS connection handle.\n @param   isSupport [IN] Indicates whether to perform cookie exchange.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetDtlsCookieExangeSupport(ctx: *const HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets whether to send handshake messages by flight distance.\n\n @param   ctx [IN/OUT] TLS connection handle.\n @param   isEnable [IN] Indicates whether to enable handshake information sending by flight distance.\n The value 0 indicates disable, other values indicate enable.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetFlightTransmitSwitch(ctx: *mut HITLS_Ctx, isEnable: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtains the status of whether to send handshake information according to the flight distance.\n\n @param   ctx [IN] TLS connection handle.\n @param   isEnable [OUT] Indicates whether to send handshake information by flight distance\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetFlightTransmitSwitch(ctx: *const HITLS_Ctx, isEnable: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   set the max empty records number can be received\n\n @param   ctx [IN/OUT] TLS connection handle.\n @param   emptyNum [IN] Indicates the max number of empty records can be received\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetEmptyRecordsNum(ctx: *mut HITLS_Ctx, emptyNum: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the max empty records number can be received\n\n @param   ctx [IN] TLS connection handle.\n @param   emptyNum [OUT] Indicates the max number of empty records can be received\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetEmptyRecordsNum(ctx: *const HITLS_Ctx, emptyNum: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   set the max send fragment to restrict the amount of plaintext bytes in any record\n\n @param   ctx [IN/OUT] TLS connection handle.\n @param   maxSendFragment [IN] Indicates the max send fragment\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_CONFIG_INVALID_LENGTH, the maxSendFragment is less than 64 or greater than 16384.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetMaxSendFragment(ctx: *mut HITLS_Ctx, maxSendFragment: u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the max send fragment to restrict the amount of plaintext bytes in any record\n\n @param   ctx [IN] TLS connection handle.\n @param   maxSendFragment [OUT] Indicates the max send fragment\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetMaxSendFragment(ctx: *const HITLS_Ctx, maxSendFragment: *mut u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set the rec inbuffer inital size\n\n @param   ctx [IN/OUT] TLS connection handle.\n @param   recInbufferSize [IN] Indicates the rec inbuffer inital size\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_CONFIG_INVALID_LENGTH, the recInbufferSize is less than 512 or greater than 18432.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetRecInbufferSize(ctx: *mut HITLS_Ctx, recInbufferSize: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the rec inbuffer inital size\n\n @param   ctx [IN] TLS connection handle.\n @param   recInbufferSize [OUT] Indicates the rec inbuffer inital size\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetRecInbufferSize(ctx: *const HITLS_Ctx, recInbufferSize: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets the maximum size of the certificate chain that can be sent from the peer end.\n\n @param   ctx [IN/OUT] TLS connection handle.\n @param   maxSize [IN] Sets the maximum size of the certificate chain that can be sent from the peer end.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetMaxCertList(ctx: *mut HITLS_Ctx, maxSize: u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtains the maximum size of the certificate chain that can be sent by the peer end.\n\n @param   ctx [IN] TLS connection handle.\n @param   maxSize [OUT] Maximum size of the certificate chain that can be sent from the peer end.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetMaxCertList(ctx: *const HITLS_Ctx, maxSize: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   This interface is valid only on the server. When the post-handshake command is configured,\n          the client identity is verified through this interface.\n\n @param   ctx [IN] TLS Connection Handle\n @retval  HITLS_INVALID_INPUT, invalid input parameter.\n @retval  HITLS_SUCCESS, if successful.\n @retval  For details about other error codes, see hitls_error.h."]
    pub fn HITLS_VerifyClientPostHandshake(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the legacy version from client hello.\n @attention This interface is valid only in client hello callback.\n @param   ctx [IN] TLS connection handle.\n @param   out [OUT] Pointer to the output buffer for legacy version.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_ClientHelloGetLegacyVersion(ctx: *mut HITLS_Ctx, version: *mut u16) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the random value from client hello.\n\n @attention This interface is valid only in client hello callback.\n @param   ctx [IN] TLS connection handle.\n @param   out [OUT] Pointer to the output buffer for random value.\n @param   outlen [IN] Length of the output buffer.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_ClientHelloGetRandom(
        ctx: *mut HITLS_Ctx,
        out: *mut *mut u8,
        outlen: *mut u8,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the session ID from client hello.\n\n @attention This interface is valid only in client hello callback.\n @param   ctx [IN] TLS connection handle.\n @param   out [OUT] Pointer to the output buffer for session ID.\n @param   outlen [OUT] Length of the output buffer.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_ClientHelloGetSessionID(
        ctx: *mut HITLS_Ctx,
        out: *mut *mut u8,
        outlen: *mut u8,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the cipher suites from client hello.\n\n @attention This interface is valid only in client hello callback.\n @param   ctx [IN] TLS connection handle.\n @param   out [OUT] Pointer to the output buffer for cipher suites.\n @param   outlen [OUT] Length of the output buffer.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_ClientHelloGetCiphers(
        ctx: *mut HITLS_Ctx,
        out: *mut *mut u16,
        outlen: *mut u16,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain the all extension types from client hello.\n\n @attention This interface is valid only in client hello callback.\n @attention the caller must release the storage allocated for *out using BSL_SAL_FREE().\n @param   ctx [IN] TLS connection handle.\n @param   out [OUT] Pointer to the output buffer for all extensions.\n @param   outlen [OUT] Length of the output buffer.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_ClientHelloGetExtensionsPresent(
        ctx: *mut HITLS_Ctx,
        out: *mut *mut u16,
        outlen: *mut u8,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain a specific extension from client hello.\n\n @attention This interface is valid only in client hello callback.\n @param   ctx [IN] TLS connection handle.\n @param   type [IN] Type of the extension to be obtained.\n @param   out [OUT] Pointer to the output buffer for the extension.\n @param   outlen [OUT] Length of the output buffer.\n @retval  HITLS_SUCCESS, if successful.\n          For details about other error codes, see hitls_error.h."]
    pub fn HITLS_ClientHelloGetExtension(
        ctx: *mut HITLS_Ctx,
        type_: u16,
        out: *mut *mut u8,
        outlen: *mut u32,
    ) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Handle the timeout of sending and receiving DTLS messages.\n\n @param   ctx [IN] TLS Connection Handle\n @retval  HITLS_SUCCESS, if retransmit the message successful.\n @retval  HITLS_MSG_HANDLE_DTLS_RETRANSMIT_NOT_TIMEOUT, It hasn't timed out yet.\n @retval  For details about other error codes, see hitls_error.h."]
    pub fn HITLS_DtlsProcessTimeout(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Get the remaining timeout time for timeout retransmission.\n\n @param   ctx [IN] TLS Connection Handle\n @param   remainTimeOut [OUT] remaining timeout time for timeout retransmission, unit: us\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_MSG_HANDLE_ERR_WITHOUT_TIMEOUT_ACTION, Indicates non UDP links or absence of timeout behavior.\n @retval  For details about other error codes, see hitls_error.h."]
    pub fn HITLS_DtlsGetTimeout(ctx: *mut HITLS_Ctx, remainTimeOut: *mut u64) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets whether to support middle box compat mode.\n\n @param   ctx [IN] TLS Connection Handle.\n @param   isMiddleBox [IN] Support or Not.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_SetMiddleBoxCompat(ctx: *mut HITLS_Ctx, isMiddleBox: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Obtain whether middle box compat mode is supported.\n\n @param   ctx [IN] TLS connection handle.\n @param   isMiddleBox [OUT] Support or Not.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetMiddleBoxCompat(ctx: *mut HITLS_Ctx, isMiddleBox: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @brief   Obtain the record out buffer remaining size\n\n @param   ctx [IN] TLS connection handle\n @param   size [OUT] record out buffer remaining size\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL.\n @retval  HITLS_SUCCESS, if successful."]
    pub fn HITLS_GetOutPendingSize(ctx: *const HITLS_Ctx, size: *mut u32) -> i32;
}

unsafe extern "C" {
    #[doc = " @brief   Flush the record out buffer\n\n @param   ctx [IN] TLS connection handle\n\n @retval  HITLS_SUCCESS Out buffer is empty or flush success\n @retval  HITLS_REC_NORMAL_IO_BUSY Out buffer is not empty, but the IO operation is busy"]
    pub fn HITLS_Flush(ctx: *mut HITLS_Ctx) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Sets whether to forcibly support extended master keys.\n\n @param   ctx [IN] TLS connection handle\n @param   support [IN] Indicates whether to forcibly support extended master keys.\nThe options are as follows: True: yes; False: no. The default value is true.\n @retval  HITLS_SUCCESS.\n @retval  HITLS_NULL_INPUT, ctx is NULL."]
    pub fn HITLS_SetExtenedMasterSecretSupport(ctx: *mut HITLS_Ctx, support: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Query whether extended master keys are supported.\n\n @param   ctx [IN] TLS connection handle\n @param   isSupport   [OUT] Indicates whether to support the extended master key.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is NULL."]
    pub fn HITLS_GetExtenedMasterSecretSupport(ctx: *mut HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Set whether to support session restoration during renegotiation.\n By default, session restoration is not supported.\n @param   ctx [IN] TLS connection handle\n @param   support  [IN] Whether to support the function. The options are as follows: True: yes; False: no.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is null."]
    pub fn HITLS_SetResumptionOnRenegoSupport(ctx: *mut HITLS_Ctx, support: bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Get whether to support session restoration during renegotiation.\n By default, session restoration is not supported.\n @param   ctx [IN] TLS connection handle\n @param   isSupport  [OUT] Indicates whether to support session restoration during renegotiation.\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, ctx is null."]
    pub fn HITLS_GetResumptionOnRenegoSupport(ctx: *mut HITLS_Ctx, isSupport: *mut bool) -> i32;
}

unsafe extern "C" {
    #[doc = " @ingroup hitls\n @brief   Get whether to allow a renegotiate request from the client\n @param   ctx   [IN] TLS connection handle.\n @param   isSupport  [OUT] Indicates whether to allow a renegotiate request from the client\n @retval  HITLS_SUCCESS, if successful.\n @retval  HITLS_NULL_INPUT, the input parameter pointer is NULL."]
    pub fn HITLS_GetClientRenegotiateSupport(ctx: *mut HITLS_Ctx, isSupport: *mut bool) -> i32;
}

